﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Models;

namespace Workflow.Project
{
    public partial class Search : System.Web.UI.Page
    {
        private PJSearchManager objPJSearch = new PJSearchManager();
        public List<ProjectMain> resultList = new List<ProjectMain>();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                int pjId1 = objPJSearch.GetId(txtNo1.Text.ToString().Trim().ToUpper());
                int pjId2=-1;
                if(txtNo2.Text.ToString().Trim()!="")
                {
                    pjId2 = objPJSearch.GetId(txtNo2.Text.ToString().Trim().ToUpper());
                }
                PJSearch pjSearch = new PJSearch()
                {
                    Id1 = pjId1,
                    Id2 = pjId2,
                    PJId=txtNo1.Text.ToString().Trim().ToUpper(),
                    PJName = txtPJName.Text.ToString().Trim(),
                    CreaterName = txtPJCreater.Text.ToString().Trim(),
                    PJType = ddlPJType.SelectedValue,
                    MoldType = ddlMoldType.SelectedValue
                };
            
                    resultList = objPJSearch.GetMain(pjSearch);
            }
            catch (Exception ex)
            {
                string msg = string.Format("<script>alert('{0}')</script>", ex.Message);
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", msg);
            }
            
        }
    }
}